import {createNativeStackNavigator} from '@react-navigation/native-stack';
import MoreView from '@/view/More';
import PetsTabBar from '@/components/TabBar';
import SetView from '@/view/Setting';
import {NavigationContainer} from '@react-navigation/native';
import Login from '@/view/Login';
import {NativeBaseProvider} from 'native-base';
import {navigationTheme, theme} from '@/utils/theme';
import Search from '@/view/Search';
import Address from '@/view/Address';
import Location from '@/components/Location';
import routeNavigation from '@/utils/routeNavigation';
const Stack = createNativeStackNavigator();
const config = {
  dependencies: {
    // For Expo projects (Bare or managed workflow)
    // 'linear-gradient': require('expo-linear-gradient').LinearGradient,
    // For non expo projects
    'linear-gradient': require('react-native-linear-gradient').default,
  },
};

export default function () {
  return (
    <NavigationContainer theme={navigationTheme} ref={routeNavigation}>
      <NativeBaseProvider theme={theme} config={config}>
        <Stack.Navigator
          initialRouteName="main"
          screenOptions={({route, navigation}) => ({
            headerShown: false,
            headerShadowVisible: false,
            headerStyle: {
              backgroundColor: theme.colors.background,
            },
            headerBackTitleVisible: false,
          })}>
          <Stack.Screen
            name="main"
            component={PetsTabBar}
            options={() => ({
              headerShown: false,
            })}
          />
          <Stack.Screen name="more" component={MoreView} options={() => ({})} />
          <Stack.Screen name="setting" component={SetView} />
          <Stack.Screen
            name="search"
            component={Search}
            options={() => ({
              headerShown: false,
            })}
          />
          <Stack.Screen
            name="login"
            component={Login}
            options={() => ({
              title: '登录',
              headerShown: true,
            })}
          />
          <Stack.Screen
            name="address"
            component={Address}
            options={() => ({
              title: '地址',
              headerLeft: () => {
                return <Location />;
              },
              headerShown: true,
            })}
          />
        </Stack.Navigator>
      </NativeBaseProvider>
    </NavigationContainer>
  );
}
